function sendAppView(a) {
    var b = "";
    chrome.storage.local.get("whatsApp_theme",
    function(c) {
        b = c.whatsApp_theme,
        "dark" == b ? a.sendAppView("darkView") : a.sendAppView("lightView")
    })
}
function sendAppNum(a) {
    var b = "";
    if ("undefined" != typeof localStorage.waMyNum && "" !== localStorage.waMyNum) {
        b = localStorage.waMyNum,
        a.send(NUMBER_EVENT.label(b));
        var c = chrome.runtime.getManifest(),
        d = "";
        c.version && (d = c.version),
        wdPost("whatsdock", {
            waid: b,
            version: d
        })
    } else window.setTimeout(function() {
        sendAppNum(a)
    },
    1e3)
}
function sendAppRate(a, b) {
    var c = analytics.EventBuilder.builder().category("rate").action(a);
    tracker.send(c.label(b))
}
function startApp() {
    service = analytics.getService("whatsDock"),
    service.getConfig().addCallback(initAnalyticsConfig),
    tracker = service.getTracker("UA-40620403-10"),
    sendAppNum(tracker),
    setInterval(function() {
        sendAppNum(tracker)
    },
    36e4)
}
function initAnalyticsConfig(a) {
    a.setTrackingPermitted("true")
}
function setupAnalyticsListener() {
    previous = [],
    tracker.addFilter(analytics.filters.FilterBuilder.builder().whenHitType(analytics.HitTypes.EVENT).whenValue(analytics.Parameters.EVENT_CATEGORY, "Theme").whenValue(analytics.Parameters.EVENT_ACTION, "change").applyFilter(function(a) {
        previous.push(a.getParameters().get(analytics.Parameters.EVENT_LABEL))
    }).build())
}
function addButtonListener(a) {
    a.addEventListener("click",
    function() {
        tracker.send(FLAVOR_EVENT.label(a.className))
    })
}
function trackSendEvent(a, b) {
    "undefined" == typeof b && (b = !1);
    var c = "";
    if (c = localStorage.waMyNum, "undefined" == typeof a) tracker.send(SEND_NUMBER_EVENT.label(c));
    else {
        if (b) var d = analytics.EventBuilder.builder().category(a).action("view");
        else var d = analytics.EventBuilder.builder().category(a).action("send");
        tracker.send(d.label(c))
    }
}
function wdPost(a, b) {
    var c = new XMLHttpRequest,
    d = "https://www.whatsdock.com/extension/" + a,
    e = postify(b);
    c.open("POST", d, !0),
    c.setRequestHeader("Content-type", "application/x-www-form-urlencoded"),
    c.onreadystatechange = function() {
        4 == c.readyState && 200 == c.status
    },
    c.send(e)
}
function wdContactChange(a) {
    var b = localStorage.waMyNum;
    "undefined" == typeof a.waid && (a.waid = b),
    wdPost("whatsdockcontacts", a)
}
function wdStats(a) {
    var b = localStorage.waMyNum;
    "undefined" == typeof a.waid && (a.waid = b),
    wdPost("stats", a)
}
function postify(a) {
    var b = "";
    if ("object" != typeof a) return b;
    for (var c in a) {
        var d = a[c];
        b += "&" + c + "=" + encodeURIComponent(d).replace(/%20/g, "+")
    }
    return "" !== b && (b = b.substr(1)),
    b
}
var FLAVOR_EVENT = analytics.EventBuilder.builder().category("Theme").action("change"),
NOTIFICATION_EVENT = analytics.EventBuilder.builder().category("Notification").action("click"),
NUMBER_EVENT = analytics.EventBuilder.builder().category("Number").action("loaded"),
SEND_NUMBER_EVENT = analytics.EventBuilder.builder().category("Number").action("send"),
service,
tracker,
previous,
currentChoice,
previousChoice;